package com.aiit.controller.user;

import com.aiit.constant.StatusConstant;
import com.aiit.entity.TeaCup;
import com.aiit.result.Result;
import com.aiit.service.TeaCupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/teaCup")
@Slf4j
@Api(tags = "客户端：茶具相关接口")
public class TeaCupController2 {

    @Autowired
    private TeaCupService teaCupService;

    /**
     * 条件查询
     *
     * @param
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("根据分类id查询套餐")
    @Cacheable(cacheNames = "teacupCache2", key = "#name != null ? #name : 'default_id'")//key : setmealCche::100
    public Result<List<TeaCup>> list(String name) {
        TeaCup teaCup = new TeaCup();
        teaCup.setName(name);
        teaCup.setStatus(StatusConstant.ENABLE);
        System.out.println("已完成用户查询");

        List<TeaCup> list = teaCupService.list(teaCup);
        return Result.success(list);
    }
}
